//
//  BoxCostHeadView.m
//  XLDoctor
//
//  Created by longma on 2018/10/8.
//  Copyright © 2018年 XLH. All rights reserved.
//

#import "MJSearchBarView.h"

@implementation MJSearchBarView


- (void)awakeFromNib{
    [super  awakeFromNib];
    
    self.searchTextField.mj_placeholderColor = UIColor.mj_lightGrayColor;
    
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
//    //适配 placeholder 太长显示不全，不会自适应调节字体
//    [self.searchTextField.superview layoutIfNeeded];
//    self.searchTextField.adjustsFontSizeToFitWidth = true;
//    NSDictionary<NSAttributedStringKey, id> *placeholderAttributes = @{NSForegroundColorAttributeName: UIColor.mj_lightGrayColor,NSFontAttributeName: self.searchTextField.font};
//    NSMutableAttributedString *attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:self.searchTextField.placeholder attributes:placeholderAttributes];
//    
//    UITextField *textField = self.searchTextField;
//    UIFont *placeholderFont = [UIFont systemFontOfSize:textField.font.pointSize];
//    
//    // 调整占位符字体大小以适应宽度
//    CGFloat textWidth = [attributedPlaceholder size].width;
//    while (textWidth > textField.bounds.size.width) {
//        placeholderFont = [UIFont systemFontOfSize:placeholderFont.pointSize - 1];
//        NSLog(@"MJLog=======placeholderFont================%lf",placeholderFont.pointSize);
//        placeholderAttributes = @{NSFontAttributeName: placeholderFont, NSForegroundColorAttributeName: UIColor.mj_lightGrayColor};
//        [attributedPlaceholder setAttributes:placeholderAttributes range:NSMakeRange(0, self.searchTextField.placeholder.length)];
//        textWidth = [attributedPlaceholder size].width;
//    }
//    
//    //  设置placeholder字体
//    self.searchTextField.attributedPlaceholder = attributedPlaceholder;
}


@end
